<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.prime.com.tr/ui">

<ui:composition template="_fornecedor.xhtml">
	<ui:define name="corpo"><br />

		<div id="conteudo">

			<h:form id="form">

				<h2>
					<h:outputText value="CADASTRAR MUNICÍPIO" />
				</h2>
				<hr /><br />

				<p:messages id="msg" />
				
				<p:fieldset legend="Dados do Municipio" toggleable="true">
				<h:panelGrid columns="3">
												
				<h:outputLabel value="Nome: " for="nome" />
				<p:inputText id="numero" value="#{municipioBean.municipio.nome}" required="true" requiredMessage="Preencha Corretamente o Campo Município">
					<f:ajax event="change" />
				</p:inputText><br /><br />
				
				<h:outputLabel value="Estado: " for="estado" />
					<h:selectOneMenu value="#{municipioBean.municipio.uf}" converter="genericConverter" required="true" requiredMessage="Escolha a Unidade da Federação do Município">
						<f:selectItem itemLabel="::Selecione::" noSelectionOption="true" />
						<f:selectItems value="#{ufBean.UFS}" var="uf" itemLabel="#{uf.sigla}" itemValue="#{uf}" />
				</h:selectOneMenu><br /><br />
				
				</h:panelGrid>
				
				<p:commandButton id="grava" value="GRAVAR" action="#{municipioBean.grava}" ajax="false" icon="ui-icon-disk">
					<f:ajax render="@all" />
				</p:commandButton>
								
				</p:fieldset>
				
			</h:form>	
				
				<p:dialog header="UNIDADE FEDERAÇÃO" widgetVar="dlgUnidade" model="true" width="150" showEffect="hide">
					<h:form id="form1">

						<p:outputPanel id="ufs">
							<p:dataTable value="#{ufBean.UFS}" var="uf" emptyMessage="Não Encontrado" style="text-align: center; float: center;">

								<p:column filterBy="#{uf.sigla}" filterMatchMode="contains"
									headerText="Sigla">
									<h:commandLink value="#{uf.sigla}" id="uf">
										<f:setPropertyActionListener
											target="#{municipioBean.municipio.uf}" value="#{uf}" />
									</h:commandLink>
								</p:column>
									
							</p:dataTable>
						</p:outputPanel>

					</h:form>
				</p:dialog>
			
		</div>


	</ui:define>
</ui:composition>
</html>